package com.wnxy.eleba.controller;

import com.github.pagehelper.PageInfo;
import com.wnxy.eleba.entity.Rider;
import com.wnxy.eleba.utils.Result;
import com.wnxy.eleba.service.RiderService_wzj;
import com.wnxy.eleba.vo.RiderQueryParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@CrossOrigin
@RestController
@RequestMapping("/rider")
public class RiderController_wzj {

    private RiderService_wzj riderService_wzj;

    public final Logger logger = LoggerFactory.getLogger(SjController_zhuying.class);

    @Autowired
    public void setRiderService_wzj(RiderService_wzj riderService_wzj) {
        this.riderService_wzj = riderService_wzj;
    }

    @PostMapping("/listRiderPageByCondition")
    public Result listRider(@RequestBody RiderQueryParam riderQueryParam){
        PageInfo<Rider> pageInfo = riderService_wzj.listPageRider(riderQueryParam);
        return Result.ok().data("pageInfo",pageInfo);
    }

    @GetMapping("/findRiderById")
    public Result findrider(@RequestParam("riderId") Integer riderId){
        Rider rider = riderService_wzj.findRiderById(riderId);
        return Result.ok().data("rider",rider);
    }

    @PostMapping("/update")
    public Result updaterider(@RequestBody Rider rider){
        boolean result = riderService_wzj.updateRider(rider);
        return Result.ok().success(result);
    }

    @PostMapping("/delete")
    public Result delrider(@RequestBody Integer... ids){
        boolean result = riderService_wzj.delriders(ids);
        return Result.ok().success(result);
    }

}
